<template>
	<view v-if="!loading && supplierIsDelete != 1">
		<block v-if="config.appId != 10002">
			<apply v-if="form || supplierStatus == -1"></apply>
			<application v-else @reset-form="resetForm"></application>
		</block>
		<block v-else>
			<apply2 v-if="form || supplierStatus == -1"></apply2>
			<application v-else @reset-form="resetForm"></application>
		</block>
	</view>
</template>

<script>
	import apply from './apply.vue';
	import application from './application_status.vue';
	import apply2 from './merchantSettlement.vue';
	import config from '@/env/config.js';
	export default {
		components: {
			apply,
			application,
			apply2
		},
		data() {
			return {
				supplierStatus: -100,
				supplierIsDelete: 0,
				form: false,
				loading: true
			};
		},
		onLoad() {
			console.log('llll', this.config.appId);
			this.getData();
		},
		methods: {
			getData() {
				let self = this;
				uni.showLoading({
					title: '加载中...'
				});
				self.loading = true;
				self._post('supplier/apply/detail', {}, res => {
					self.supplierIsDelete = res.data.supplierIsDelete;
					if (res.data.status || res.data.status == 0) {
						self.supplierStatus = res.data.status;
					} else {
						self.supplierStatus = -1;
					}
					if (self.supplierStatus == 1 && res.data.supplierIsDelete != 1) {
						self.supplierStatus = res.data.status;
						if (self.config.appId == 10002) {
							uni.showToast({
								title: '您已是商家',
								icon: 'none'
							})
							setTimeout(function() {
								uni.navigateBack({})
							}, 1000);

						} else {
							self.gotoPage('pages/user/my_shop/my_shop', 'redirect');
						}

					} else if (res.data.supplierIsDelete == 1) {
						uni.hideLoading();
						uni.showModal({
							content: '店铺异常,请联系客服处理'
						});
					} else {
						let title = '';
						if (self.supplierStatus == 0) {
							title = '申请入驻';
						} else {
							title = '申请审核中';
						}
						uni.setNavigationBarTitle({
							title: title
						});

						self.loading = false;
						uni.hideLoading();
					}
				});
			},
			resetForm() {
				this.form = true;
				console.log('llll');
			}
		}
	};
</script>

<style></style>